package zero.tech.games.logic.topic;

import com.alibaba.fastjson.JSONObject;

import zero.tech.core.work.WorkManager;
import zero.tech.games.common.TopicOrder;
import zero.tech.games.common.gm.GmFreeRoom;
import zero.tech.games.logic.common.CacheRoom;
import zero.tech.games.logic.common.Room;
import zero.tech.games.logic.work.room.FreeRoomWork;
import zero.tech.redis.topic.TopicChannelType;
import zero.tech.redis.topic.TopicProcess;

public class FreeRoom extends TopicProcess{

	@Override
	public String orderType() {
		return TopicOrder.GM_FREE_ROOM;
	}

	@Override
	public void process(String message) throws Exception {
		GmFreeRoom gmFreeRoom = JSONObject.parseObject(message, GmFreeRoom.class);
		String room_id=gmFreeRoom.getRoom_id();
		Room room=CacheRoom.getCache().getRooms().get(room_id);
		if(room!=null) {
			WorkManager.getManager().submit(FreeRoomWork.class,room);
		}
	}

	@Override
	public TopicChannelType channelType() {
		return TopicChannelType.DEFAULT;
	}

}
